Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exporting lib ndk internals #1606

Merged
merged 2 commits into from
Feb 28, 2022

Conversation

kattrali
Copy link
Contributor

Goal

Only expose the minimum surface required to make the library work, via a linker version script. They should be:

  • Java_* for JNI functions
  • bugsnag_* for the native API
  • __cxa*, __gxx* and friends for C++ exception handling

Changeset

  • Add linker script to build process
  • Remove exception property reporting dependent on arbitrary type info being present

Testing

Tested manually that exception handling still worked as expected, though this change should be covered by the existing tests and addition of a specific test for C++ exception handling.

reduce the surface of API, which expanded quite a bit with updated
unwindstack.

https://developer.android.com/ndk/guides/middleware-vendors

debug builds export additional symbols used in the tests

This change requires removal of code which re-throws types defined in
binaries other than libbugsnag-ndk, because if the type has been hidden,
then the throw invocation will trigger an immediate termination
(skipping the crash report), or if the type is custom (e.g. a subclass
of std::runtime_error, etc), then no useful message was detected anyway,
as the type information is likely not available.

Useful reading on the topic:

* https://gcc.gnu.org/wiki/Visibility (specifically "Problems with C++
  exceptions")
* https://developer.android.com/ndk/guides/common-problems#rttiexceptions_not_working_across_library_boundaries
* https://developer.android.com/ndk/guides/cpp-support#ic
* https://en.cppreference.com/w/cpp/language/definition (section on ODR)

Technically this lib should not export std:: symbols but this at least
preserves existing behavior until its re-evaluated.

[full ci]
@kattrali kattrali requested a review from lemnik February 23, 2022 17:06
Copy link
Contributor

@lemnik lemnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kattrali kattrali merged commit 38e8cf5 into integration/update-unwinder Feb 28, 2022
@kattrali kattrali deleted the kattrali/unwinder-hide-syms branch February 28, 2022 14:16
This was referenced Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants